﻿using System;
using System.Collections.Generic;
using System.Data.Services;
using System.Data.Services.Common;
using System.Linq;
using System.ServiceModel.Web;
using System.Web;
using AstoriaPlus;
using System.ServiceModel.Activation;
using System.ComponentModel.Composition.Hosting;
using System.Diagnostics;
using System.IO;

namespace WebApp
{
	public class Entities : PipelineDataService<EntitiesContainer>
	{
		static readonly CompositionContainer container;

		static Entities()
		{
			container = new CompositionContainer(new DirectoryCatalog(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bin")));
		}

		public Entities()
			: base(container.GetExportedValues<IPipelineBehavior>())
		{
		}

		public static void InitializeService(DataServiceConfiguration config)
		{
			config.SetEntitySetAccessRule("*", EntitySetRights.All);
			config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
		}
	}
}
